package com.fsds.crem.web.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.fsds.crem.core.feature.orm.mybatis.Page;
import com.fsds.crem.web.dao.TimeTaskLogDao;
import com.fsds.crem.web.entity.TimeTaskLog;
import com.fsds.crem.web.service.TimeTaskLogService;

@Service("timeTaskLogService")
public class TimeTaskLogServiceImpl implements TimeTaskLogService {

	@Resource
	private TimeTaskLogDao timeTaskLogDao;
	
	@Override
	public Page<TimeTaskLog> findByPage(TimeTaskLog log,Page<TimeTaskLog> page) {
		
		page.setResult(timeTaskLogDao.findByPage(log, page));
		
		return page;
	}

	@Override
	public void saveTimeTaskLog(TimeTaskLog log) {

		TimeTaskLog oldLog = timeTaskLogDao.findByCreateDate(log);
		
		// 该报表已有记录，就修改记录
		if(oldLog != null){
			
			log.setId(oldLog.getId());
			timeTaskLogDao.update(log);
		}
		// 没有记录时新增记录
		else{
			
			timeTaskLogDao.create(log);
		}
	}

}
